package han.yang.service.friendship.controller;

import han.yang.common.ResponseVO;
import han.yang.service.friendship.model.req.*;
import han.yang.service.friendship.service.ImFriendService;
import han.yang.service.friendship.service.ImFriendShipRequestService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yanghan
 * @date 2023/2/25
 */
@RestController
@RequestMapping("v1/friendshipRequest")
public class ImFriendShipRequestController {
    @Resource
    ImFriendShipRequestService imFriendShipRequestService;

    @RequestMapping("approveFriendRequest")
    public ResponseVO approveFriendRequest(@RequestBody @Validated ApproverFriendRequestReq req, Integer appId, String identifier){
        req.setAppId(appId);
        req.setOperater(identifier);
        return imFriendShipRequestService.approverFriendRequest(req);
    }

    @RequestMapping("/readFriendShipRequestReq")
    public ResponseVO readFriendShipRequestReq(@RequestBody @Validated ReadFriendShipRequestReq req, Integer appId){
        req.setAppId(appId);
        return imFriendShipRequestService.readFriendShipRequestReq(req);
    }

    @RequestMapping("/getFriendRequest")
    public ResponseVO getFriendRequest(@RequestBody @Validated GetFriendShipRequestReq req, Integer appId){
        req.setAppId(appId);
        return imFriendShipRequestService.getFriendRequest(req.getUserId(),req.getAppId());
    }
}
